package com.daigoudao.web.action;

import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.daigoudao.config.ConfigManager;
import com.daigoudao.util.Constants;
import com.daigoudao.util.FileUtil;
import com.daigoudao.util.StringUtils;
import com.daigoudao.web.common.BasePageAction;
import com.daigoudao.web.model.AppealsModel;
import com.daigoudao.web.model.InviteModel;
import com.daigoudao.web.model.PurchaseRecord;
import com.daigoudao.web.model.ShortMessage;
import com.daigoudao.web.model.SimpleBuyModel;
import com.daigoudao.web.model.TransInfoModel;
import com.daigoudao.web.model.UserModel;
import com.daigoudao.web.model.WantBuyModel;
import com.daigoudao.web.service.IAnnounceService;
import com.daigoudao.web.service.IAppealsService;
import com.daigoudao.web.service.IInviteService;
import com.daigoudao.web.service.IShortMessageService;
import com.daigoudao.web.service.ITransInfoService;
import com.daigoudao.web.service.IUserAddrService;
import com.daigoudao.web.service.IUserService;
import com.daigoudao.web.service.IWantBuyService;

public class UserInfoAction extends BasePageAction {

	private static final long serialVersionUID = 1L;

	private static Logger logger = LoggerFactory
			.getLogger(UserInfoAction.class);

	private IShortMessageService shortMessageService;

	private IAppealsService appealsService;

	ITransInfoService transInfoService;

	IWantBuyService wantBuyService;

	IInviteService inviteService;

	IAnnounceService announceService;

	private IUserService userService;

	private List<UserModel> followList;

	private List<ShortMessage> messageList;

	private int brokerEvaluation;

	private int selectMode = -1;

	private int state = -1;

	private int receiptNum;

	private int evaluateNum;

	private int messageNum;

	private int payNum;

	private int wantBuyNum;

	private int inviteNum;

	private UserModel userModel;

	private String name;

	private int[] smids;

	private List<AppealsModel> appeals;

	private int userType;

	private int simpleid;

	private int receiver;

	private int replyId;

	private int smid;

	private List<InviteModel> inviteList;

	private List<TransInfoModel> orders;

	private List<WantBuyModel> wantBuyList;
	// 搭车代购
	private List<SimpleBuyModel> simpleBuyList;

	private String content;

	public int getReceiver() {
		return receiver;
	}

	public void setReceiver(int receiver) {
		this.receiver = receiver;
	}

	public int getReplyId() {
		return replyId;
	}

	public void setReplyId(int replyId) {
		this.replyId = replyId;
	}

	public int getSmid() {
		return smid;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getContent() {
		return content;
	}

	public void setSmid(int smid) {
		this.smid = smid;
	}

	public void setSmids(int[] smids) {
		this.smids = smids;
	}

	public int getSimpleid() {
		return simpleid;
	}

	public void setSimpleid(int simpleid) {
		this.simpleid = simpleid;
	}

	public List<SimpleBuyModel> getSimpleBuyList() {
		return simpleBuyList;
	}

	public void setSimpleBuyList(List<SimpleBuyModel> simpleBuyList) {
		this.simpleBuyList = simpleBuyList;
	}

	private int invitOper;

	private boolean setAddress;

	private List<PurchaseRecord> records;

	private int cbox;

	private int productId;

	private AppealsModel appeal;

	private IUserAddrService userAddrService;

	public void setUserAddrService(IUserAddrService userAddrService) {
		this.userAddrService = userAddrService;
	}

	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public int getSelectMode() {
		return selectMode;
	}

	public void setSelectMode(int selectMode) {
		this.selectMode = selectMode;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public void setMessageList(List<ShortMessage> messageList) {
		this.messageList = messageList;
	}

	public List<PurchaseRecord> getRecords() {
		return records;
	}

	public int getWantBuyNum() {
		return wantBuyNum;
	}

	public void setWantBuyNum(int wantBuyNum) {
		this.wantBuyNum = wantBuyNum;
	}

	public int getInviteNum() {
		return inviteNum;
	}

	public void setInviteNum(int inviteNum) {
		this.inviteNum = inviteNum;
	}

	public int getReceiptNum() {
		return receiptNum;
	}

	public void setReceiptNum(int receiptNum) {
		this.receiptNum = receiptNum;
	}

	public int getEvaluateNum() {
		return evaluateNum;
	}

	public void setEvaluateNum(int evaluateNum) {
		this.evaluateNum = evaluateNum;
	}

	public int getPayNum() {
		return payNum;
	}

	public void setPayNum(int payNum) {
		this.payNum = payNum;
	}

	public List<ShortMessage> getMessageList() {
		return messageList;
	}

	public int getBrokerEvaluation() {
		return brokerEvaluation;
	}

	public void setBrokerEvaluation(int brokerEvaluation) {
		this.brokerEvaluation = brokerEvaluation;
	}

	public List<UserModel> getFollowList() {
		return followList;
	}

	public void setFollowList(List<UserModel> followList) {
		this.followList = followList;
	}

	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

	public void setAnnounceService(IAnnounceService announceService) {
		this.announceService = announceService;
	}

	public void setInviteService(IInviteService inviteService) {
		this.inviteService = inviteService;
	}

	public void setWantBuyService(IWantBuyService wantBuyService) {
		this.wantBuyService = wantBuyService;
	}

	public void setTransInfoService(ITransInfoService transInfoService) {
		this.transInfoService = transInfoService;
	}

	public void setAppealsService(IAppealsService appealsService) {
		this.appealsService = appealsService;
	}

	public void setShortMessageService(IShortMessageService shortMessageService) {
		this.shortMessageService = shortMessageService;
	}

	public void setAppeal(AppealsModel appeal) {
		this.appeal = appeal;
	}

	public AppealsModel getAppeal() {
		return appeal;
	}

	public int getCbox() {
		return cbox;
	}

	public void setCbox(int cbox) {
		this.cbox = cbox;
	}

	public boolean isSetAddress() {
		return setAddress;
	}

	// 头像上传
	private List<File> file;
	private List<String> fileFileName;
	private List<String> fileContentType;

	public List<File> getFile() {
		return file;
	}

	public void setFile(List<File> file) {
		this.file = file;
	}

	public List<String> getFileFileName() {
		return fileFileName;
	}

	public void setFileFileName(List<String> fileFileName) {
		this.fileFileName = fileFileName;
	}

	public List<String> getFileContentType() {
		return fileContentType;
	}

	public void setFileContentType(List<String> fileContentType) {
		this.fileContentType = fileContentType;
	}

	public int getInvitOper() {
		return invitOper;
	}

	public void setInvitOper(int invitOper) {
		this.invitOper = invitOper;
	}

	public List<InviteModel> getInviteList() {
		return inviteList;
	}

	public void setInviteList(List<InviteModel> inviteList) {
		this.inviteList = inviteList;
	}

	public List<WantBuyModel> getWantBuyList() {
		return wantBuyList;
	}

	public void setWantBuyList(List<WantBuyModel> wantBuyList) {
		this.wantBuyList = wantBuyList;
	}

	public List<TransInfoModel> getOrders() {
		return orders;
	}

	public int getUserType() {
		return userType;
	}

	public void setUserType(int userType) {
		this.userType = userType;
	}

	public List<AppealsModel> getAppeals() {
		return appeals;
	}

	public void setAppeals(List<AppealsModel> appeals) {
		this.appeals = appeals;
	}

	public UserModel getUserModel() {
		return userModel;
	}

	public void setUserModel(UserModel userModel) {
		this.userModel = userModel;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getMessageNum() {
		return messageNum;
	}

	/**
	 * 获取发布的求购信息数
	 * 
	 * @return
	 */
	public String countWantBuys() {
		if (isLogin()) {
			UserModel user = getUserLogin();
			WantBuyModel wantBuyModel = new WantBuyModel();
			wantBuyModel.getUser().setUserid(user.getUserid());
			try {
				wantBuyNum = wantBuyService.getMyWantBuyCount(wantBuyModel);
			} catch (Exception e) {
				logger.error("countWantBuys error.", e);
			}
		}
		return SUCCESS;
	}

	/**
	 * 获取待确认邀约数
	 * 
	 * @return
	 */
	public String countInvites() {
		if (isLogin()) {
			UserModel user = getUserLogin();
			InviteModel statInvite = new InviteModel();
			statInvite.setWantUserId(user.getUserid());
			statInvite.setSelectMode(0);
			try {
				inviteNum = inviteService.getInviteCount(statInvite);
			} catch (Exception e) {
				logger.error("getInviteNum error.", e);
			}
		}
		return SUCCESS;
	}

	/**
	 * 获取未读短消息数
	 * 
	 * @return
	 */
	public String countMessages() {
		if (isLogin()) {
			ShortMessage statMessage = new ShortMessage();
			statMessage.setSender(getUserLogin().getUserid());
			statMessage.setRead(0);
			statMessage.setReplyTag(2);
			try {
				messageNum = shortMessageService
						.getShortMessageCountByBuyer(statMessage);
			} catch (Exception e) {
				logger.error("getMessageNum error.", e);
			}
		}
		return SUCCESS;
	}

	public String replyMsg() {
		if (!isLogin()) {
			return LOGIN;
		}
		ShortMessage replyMessage = new ShortMessage();
		replyMessage.setReceiver(receiver);
		replyMessage.setReplyTag(1);
		replyMessage.setReplyid(replyId);
		replyMessage.setMainSmid(smid);
		replyMessage.setContent(content);
		replyMessage.setCreatetime(new Date());

		replyMessage.setSender(getUserLogin().getUserid());
		try {
			shortMessageService.addReplyMessage(replyMessage);
		} catch (Exception e) {
			LOG.error("reply error.", e);
			return ERROR;
		}
		action = "inituser.htm";
		return SUCCESS;
	}

	/**
	 * 分组统计交易数量
	 * 
	 * @return
	 */
	public String groupTransInfo() {
		if (isLogin()) {
			UserModel user = getUserLogin();
			try {
				Map<Integer, Integer> groups = transInfoService
						.groupTransInfoByUser(user.getUserid());
				payNum = groups.get(0) == null ? 0 : groups.get(0);
				receiptNum = groups.get(2) == null ? 0 : groups.get(2);
				evaluateNum = groups.get(3) == null ? 0 : groups.get(3);

			} catch (Exception e) {
				logger.error("groupTransInfo error", e);
			}
		}
		return SUCCESS;
	}

	@SuppressWarnings("unchecked")
	public String initUserInfo() {
		if (logger.isDebugEnabled()) {
			logger.debug("initUserInfo");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "inituser.htm?read=" + getRead());
			return LOGIN;
		}

		ShortMessage queryMessage = new ShortMessage();
		queryMessage.setSender(getUserLogin().getUserid());
		queryMessage.setStartIndex((getSuperPage() - 1) * getPageSize());
		queryMessage.setPageSize(getPageSize());
		queryMessage.setRead(read);
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			messageList = shortMessageService
					.queryShortMessagesByBuyer(queryMessage);
			setTotalSize(shortMessageService
					.getShortMessageCountByBuyer(queryMessage));
		} catch (Exception e) {
			logger.error("query messages error.", e);
			return ERROR;
		}
		return SUCCESS;
	}

	@SuppressWarnings("unchecked")
	public String queryAppealsByOwnerId() {
		if (logger.isDebugEnabled()) {
			logger.debug("queryAppealsByOwnerId");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "queryAppealsByOwnerId.htm");
			return LOGIN;
		}

		AppealsModel appealsModel = new AppealsModel();
		appealsModel.setOwnerid(getUserLogin().getUserid());
		appealsModel.setStartIndex((getSuperPage() - 1) * getPageSize());
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			appeals = appealsService.queryAppeals(appealsModel);
			setTotalSize(appealsService.getAppealCount(appealsModel));
		} catch (Exception e) {
			logger.error("selectAppealsByOwnerId Exception", e);
			return ERROR;
		}

		if (userType == Constants.USER_TYPE_GENERAL) {
			return "UserSucc";
		} else {
			return "AgentSucc";
		}
	}

	@SuppressWarnings("unchecked")
	public String queryAppealsById() {
		if (logger.isDebugEnabled()) {
			logger.debug("queryAppealsById");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "queryAppealsById.htm");
			return LOGIN;
		}

		AppealsModel appealsModel = new AppealsModel();
		if (userType == Constants.USER_TYPE_BROKER) {
			appealsModel.setTargetid(getUserLogin().getUserid());
		} else {
			appealsModel.setOwnerid(getUserLogin().getUserid());
		}

		appealsModel.setStartIndex((getSuperPage() - 1) * getPageSize());
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			appeals = appealsService.queryAppeals(appealsModel);
			setTotalSize(appealsService.getAppealCount(appealsModel));
		} catch (Exception e) {
			logger.error("queryAppealsById Exception", e);
			return ERROR;
		}

		if (userType == Constants.USER_TYPE_GENERAL) {
			return "UserSucc";
		} else {
			return "AgentSucc";
		}
	}

	@SuppressWarnings("unchecked")
	public String initAppeals() {
		if (logger.isDebugEnabled()) {
			logger.debug("initAppeals");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "initAppeals.htm");
			return LOGIN;
		}
		PurchaseRecord query = new PurchaseRecord();
		query.setStartIndex((getSuperPage() - 1) * getPageSize());
		query.getBuyer().setUserid(getUserLogin().getUserid());
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			records = transInfoService.queryPurchaseRecords(query);
			setTotalSize(transInfoService.getPurhcaseRecordCount(query));
		} catch (Exception e) {
			logger.error("initAppeals error.", e);
			return ERROR;
		}

		return SUCCESS;
	}

	public String appealsUpload() {
		if (!isLogin()) {
			return LOGIN;
		}
		String root = ConfigManager.getConfigString("upload.resDir");
		String path = StringUtils.formatDate(new Date(), "yyyy-MM-dd");
		String basePath = root + File.separator + path;
		FileUtil.createDir(basePath);

		UserModel userModel = getUserLogin();

		// 循环上传的文件
		if (file != null) {
			for (int i = 0; i < file.size(); i++) {
				// 获取文件扩展名
				String fileName = this.getFileFileName().get(i);
				String extName = FileUtil.getExtention(fileName);

				fileName = StringUtils.getUUID() + extName;
				File destFile = new File(basePath, fileName);

				// 文件复制
				try {
					FileUtil.copy(file.get(i), destFile);
				} catch (Exception e) {
				}

				// 文件在数据库存储
				String urlPath = File.separator + path + File.separator
						+ fileName;

				appeal.setOwnerid(userModel.getUserid());
				appeal.setUrl(urlPath);
				TransInfoModel query = new TransInfoModel();
				query.getBuyer().setUserid(userModel.getUserid());
				query.setOrderId(appeal.getOrderid());
				try {
					TransInfoModel tm = transInfoService
							.queryOrderDetail(query);
					if (tm == null) {
						return ERROR;
					}
					appeal.setTargetid(tm.getBroker().getUserid());
					appealsService.insertAppeal(appeal);
				} catch (Exception e) {
					logger.error("appeal error.", e);
					return ERROR;
				}
			}
		}

		return SUCCESS;

	}

	/**
	 * 我发布的求购信息
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String queryWantBuys() {
		if (logger.isDebugEnabled()) {
			logger.debug("wantBuyInfo");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "initWantBuyInfo.htm");
			return LOGIN;
		}
		userModel = getUserLogin();
		WantBuyModel query = new WantBuyModel();
		query.getUser().setUserid(userModel.getUserid());
		query.setStartIndex((getSuperPage() - 1) * getPageSize());
		query.setPageSize(getPageSize());
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			wantBuyList = wantBuyService.queryMyWantBuys(query);
			setTotalSize(wantBuyService.getMyWantBuyCount(query));
		} catch (Exception e) {
			logger.error("queryWantBuys error.", e);
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 我的搭车求购信息
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String querySimpleBuys() {
		if (logger.isDebugEnabled()) {
			logger.debug("querySimpleBuys");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "initMySimpleInfo.htm");
			return LOGIN;
		}
		userModel = getUserLogin();
		SimpleBuyModel query = new SimpleBuyModel();
		query.getUser().setUserid(userModel.getUserid());
		query.setStartIndex((getSuperPage() - 1) * getPageSize());
		query.setPageSize(getPageSize());
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			simpleBuyList = wantBuyService.queryMySimpleBuys(query);
			setTotalSize(wantBuyService.getMySimpleBuyCount(query));
		} catch (Exception e) {
			logger.error("queryWantBuys error.", e);
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 更新状态
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String updateSimpleBuysStatus() {
		if (logger.isDebugEnabled()) {
			logger.debug("updateSimpleBuysStatus");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "updateSimpleBuyStatus.htm?simpleid="
					+ simpleid + "&state=" + state);
			return LOGIN;
		}
		userModel = getUserLogin();
		SimpleBuyModel query = new SimpleBuyModel();

		// 设置状态为取消
		query.setSimpleId(getSimpleid());
		query.setStatus(state);
		try {
			wantBuyService.updateSimpleBuyStatus(query);
		} catch (Exception e) {
			logger.error("update SimpleBuyStatus error!", e);
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 我收到的代购邀约
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String myInviteinfo() {
		if (logger.isDebugEnabled()) {
			logger.debug("myInviteinfo");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "initMyInviteinfo.htm?selectMode="
					+ selectMode);
			return LOGIN;
		}
		userModel = super.getUserLogin();
		InviteModel inviteModel = new InviteModel();
		inviteModel.setWantUserId(userModel.getUserid());
		inviteModel.setStartIndex((getSuperPage() - 1) * getPageSize());
		inviteModel.setPageSize(getPageSize());
		inviteModel.setSelectMode(selectMode);
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			inviteList = inviteService.queryInviteInfos(inviteModel);
			setTotalSize(inviteService.getInviteCount(inviteModel));
		} catch (Exception e) {
			logger.error("query invite info error", e);
			return ERROR;
		}
		return SUCCESS;
	}

	@SuppressWarnings("unchecked")
	public String regectInvit() {
		if (logger.isDebugEnabled()) {
			logger.debug("regectInvit");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "refuseInvite.htm?id=" + id);
			return LOGIN;
		}
		userModel = super.getUserLogin();
		InviteModel inviteModel = new InviteModel();
		inviteModel.setWantUserId(userModel.getUserid());
		inviteModel.setInviteId(id);
		inviteModel.setSelectMode(2);
		try {
			inviteService.updateStatus(inviteModel);
		} catch (Exception e) {
			logger.error("rejectInvit error.", e);
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 正在进行的交易
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String queryBTradingInfo() {
		if (logger.isDebugEnabled()) {
			logger.debug("queryBTradingInfo");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "initBTradingInfo.htm?state=" + state);
			return LOGIN;
		}
		userModel = super.getUserLogin();
		TransInfoModel transInfoModel = new TransInfoModel();
		UserModel wantUserModel = new UserModel();
		wantUserModel.setUserid(userModel.getUserid());
		transInfoModel.setBuyer(wantUserModel);
		transInfoModel.setNotEqualState(3);
		transInfoModel.setStartIndex((getSuperPage() - 1) * getPageSize());
		transInfoModel.setPageSize(getPageSize());
		transInfoModel.setState(state);
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			orders = transInfoService.queryTransInfos(transInfoModel);
			setTotalSize(transInfoService.getTransCount(transInfoModel));
		} catch (Exception e) {
			logger.error("queryTransInfos", e);
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 交易
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String queryTradInfo() {
		if (logger.isDebugEnabled()) {
			logger.debug("queryTradInfo");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "queryTradInfo.htm");
			return LOGIN;
		}
		userModel = super.getUserLogin();
		TransInfoModel transInfoModel = new TransInfoModel();
		UserModel wantUserModel = new UserModel();
		wantUserModel.setUserid(userModel.getUserid());
		transInfoModel.setBuyer(wantUserModel);
		transInfoModel.setStartIndex((getSuperPage() - 1) * getPageSize());
		transInfoModel.setPageSize(getPageSize());
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			orders = transInfoService.queryTransInfos(transInfoModel);
			setTotalSize(transInfoService.getTransCount(transInfoModel));
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("queryTransInfos", e);
		}
		return SUCCESS;
	}

	/**
	 * 已完成的交易
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String queryBTradedInfo() {
		if (logger.isDebugEnabled()) {
			logger.debug("queryBTradedInfo");
		}
		if (!isLogin()) {
			session.put(Constants.URL, "initBTradedInfo.htm?brokerEvaluation="
					+ brokerEvaluation);
			return LOGIN;
		}
		userModel = super.getUserLogin();
		TransInfoModel transInfoModel = new TransInfoModel();
		transInfoModel.getBuyer().setUserid(userModel.getUserid());
		transInfoModel.setState(3);
		transInfoModel.setBrokerEvaluation(brokerEvaluation);
		transInfoModel.setStartIndex((getSuperPage() - 1) * getPageSize());
		transInfoModel.setPageSize(getPageSize());
		try {
			setAddress = (userAddrService.getAddrCount(getUserLogin()
					.getUserid()) == 0);
			orders = transInfoService.queryTransInfos(transInfoModel);
			setTotalSize(transInfoService.getTransCount(transInfoModel));
		} catch (Exception e) {
			logger.error("queryTransInfos", e);
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 
	 * @return
	 */
	public String queryFollowList() {
		try {
			followList = userService.getFollowList(userModel);
		} catch (Exception e) {
			logger.error("getBrokerLista Exception", e);
		}
		return SUCCESS;
	}

	/**
	 * 删除申诉信息
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String delAppeals() {
		if (!isLogin()) {
			session.put(Constants.URL, "delAppeals.htm?id=" + id);
			return LOGIN;
		}
		try {
			appealsService.deleteAppeal(id);
		} catch (Exception e) {
			logger.error("del appeals error.", e);
			return ERROR;
		}
		return SUCCESS;
	}

	public String delMessages() {
		if (logger.isDebugEnabled()) {
			logger.debug("delMessages start.");
		}
		try {
			shortMessageService.delMessages(1, smids);
		} catch (Exception e) {
			logger.error("delMessages error.", e);
			return ERROR;
		}
		if (logger.isDebugEnabled()) {
			logger.debug("delMessages end.");
		}
		action = "inituser.htm";

		return SUCCESS;
	}

	/**
	 * 已读
	 * 
	 * @return
	 */
	public String alreadyRead() {
		try {
			shortMessageService.alreadyRead(smid);
		} catch (Exception e) {
			logger.error("alreadyRead error.", e);
		}
		return null;
	}
}
